// $ = jQuery.noConflict(true);
(function ($) {
  $(document).ready(function () {

    var closeMenu = $(".close");
    var openMenu = $("#burgerMenu");
    var mobileMenu = $('#menu-mobile > ul > li');
    var subMenu = $('#menu-mobile > ul > li > ul > li');
    var html = $('html');


    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
    if (agentID) {
      // console.log("apple");
      $('.get-the-app-button').attr("href", "https://apps.apple.com/us/app/socios-com-wallet-tokens/id1464868277");

    } else {
      // console.log("android");
      $('.get-the-app-button').attr("href", "https://play.google.com/store/apps/details?id=com.socios");
    }




    openMenu.on("click", function () {
      $("#menu-mobile").removeClass("hide-menu");
      html.addClass("overflow-hidden");

    });
    // on click the X remove the menu and remove the overflow to the html

    closeMenu.on("click", function () {
      $("#menu-mobile").addClass("hide-menu");
      html.removeClass("overflow-hidden");

    });


    mobileMenu.on("click", function () {
      subMenu.toggleClass("display-none");
    });




    $('#home-play').on("click", function () { //psg
      $('.modal-2021').toggleClass("display-none");
    });
    
    //rewards video

    $('.play-button').on("click", function () { //psg
      $('.modal-psg').toggleClass("display-none");
    });

    $('.play-button-asr').on("click", function () { //roma
      $('.modal-asr').toggleClass("display-none");
    });



    $('.modal-2021').on("click", function (event) {
      var target = $(event.target);
      if (target.is("video")) {


      } else {

        // $('.modal-asr').toggleClass("display-none");
        // $('.modal-psg').toggleClass("display-none");

        // $('.modal-asr').on("click", function () {
        //   $(this).toggleClass("display-none");
        // });

        // $('.modal-psg').on("click", function () {
        //   $(this).toggleClass("display-none");
        // });

        // $('.modal-2021').on("click", function () {
          $(this).toggleClass("display-none");
        // });


        $('video').trigger('pause');
      }
      // $(".video2021").pause();
      // $(".video2021").currentTime = 0;

    });




    $('#home-final-carousel-wrapper').slick({
      infinite: true,
      dots: true,
      // centerMode: true,
      slidesToShow: 5,
      slidesToScroll: 1,
      autoplaySpeed: 3000,
      autoplay: true,
      responsive: [
        {
          breakpoint: 2300,
          settings: {
            slidesToShow: 4,
          }
        },
        {
          breakpoint: 1883,
          settings: {
            slidesToShow: 3.5,
         

          }
        },
        {
          breakpoint: 1630,
          settings: {
            slidesToShow: 3,
          }
        },
        {
          breakpoint: 1420,
          settings: {
            slidesToShow: 2.5,
          }
        },
        {
          breakpoint: 1230,
          settings: {
            slidesToShow: 2.3,
          }
        },
        {
          breakpoint: 1120,
          settings: {
            slidesToShow: 2,
          }
        },
        {
          breakpoint: 990,
          settings: {
            slidesToShow: 1.8,
          }
        },
        {
          breakpoint: 890,
          settings: {
            slidesToShow: 1,
            variableWidth: true
          }
        }
      ]
    });

    $('.video-slider').slick({
      slidesToShow: 1,
      slidesToScroll: 1,
      autoplay: true,
      autoplaySpeed: 2000,

    });

    $('.phone-home').slick({
      slidesToShow: 1,
      slidesToScroll: 1,
      autoplay: false,
      autoplaySpeed: 2000,
      arrows: false,

    });

    //this is to change the slide by clicking

    $('.single-step[data-slide]').click(function(e) {
      e.preventDefault();
      var slideno = $(this).data('slide');
      $('.phone-home').slick('slickGoTo', slideno - 1);
    });

    $('.screen-slider-hiw').slick({
      slidesToShow: 1,
      slidesToScroll: 1,
      autoplay: true,
      verticalSwiping: false,
      infinite: false,
      autoplaySpeed: 5000,
      arrows: false,
      // asNavFor: '.text-slider',
    });
    $('.text-slider').slick({
      arrows: false,
      dots: false,
      vertical: true,
      verticalSwiping: false,
      centerMode: true,
      infinite: false,
      slidesToShow: 4,
      slidesToScroll: 0,
      asNavFor: '.screen-slider-hiw',
      focusOnSelect: true,
      swipe: false,
    });


    //partners/rewards



    $('ul.tabs li').click(function () {
      var tab_id = $(this).attr('data-tab');

      $('ul.tabs li').removeClass('current');
      $('.tab-content').removeClass('current');

      $(this).addClass('current');
      $("#" + tab_id).addClass('current');
    })





  }); //document.ready



  //make a list of coin faces

  var faces = [
    "https://www.socios.com/img/coins/PSG-10.svg",
    "https://www.socios.com/img/coins/JUV-10.svg",
    "https://www.socios.com/img/coins/ACM-10.svg",
    "https://www.socios.com/img/coins/BAR-10.svg",
    "https://www.socios.com/wp-content/themes/socios2021/dist/img/remake/coins/MAN-10.svg",
    "https://www.socios.com/img/coins/PFL-10.svg",
    "https://www.socios.com/img/coins/NAVI-10.svg",
    "https://www.socios.com/img/coins/ATM-10.svg",
    "https://www.socios.com/img/coins/ASR-10.svg",
     "https://www.socios.com/wp-content/themes/socios2021/dist/img/remake/coins/UFC-10.svg",
    "https://www.socios.com/img/coins/OG-10.svg",
    "https://www.socios.com/img/coins/GAL-10.svg",
    "https://www.socios.com/img/coins/CAI-10.svg",
    "https://www.socios.com/img/coins/HER-10.svg",
    "https://www.socios.com/img/coins/APL-10.svg",
    "https://www.socios.com/img/coins/TRA-10.svg",
    "https://www.socios.com/img/coins/YBO-10.svg",
    "https://www.socios.com/img/coins/STV-10.svg",
    "https://www.socios.com/img/coins/NOV-10.svg",
    "https://www.socios.com/img/coins/IBFK-10.svg",
    "https://www.socios.com/img/coins/ALL-10.svg",
    "https://www.socios.com/img/coins/UCH-10.svg",
    "https://www.socios.com/wp-content/themes/socios2021/dist/img/remake/coins/LEG-10.svg",
    "https://www.socios.com/wp-content/themes/socios2021/dist/img/remake/coins/FOR-10.svg",
    "https://www.socios.com/wp-content/themes/socios2021/dist/img/remake/coins/GOZ-10.svg",


  ];
  $('.coin__back, .coin__front').css('background-image', 'url(' + faces[0] + ')');


  let counter = 0;
  setInterval(() => {
    counter++;
    if (counter === faces.length) {
      counter = 0;
    }
    $('.coin__back, .coin__front').css('background-image', 'url(' + faces[counter] + ')');
  }, 2000);
  

  // AMERICA
  // var detectedCountry = null ;
  // $.get("https://www.socios.com/api/location")
  //   .done( data => {
  //     var detectedCountry = data.country_code;
  //     console.log(data.country_code);

 
  //   });

    // var userId = null; // Replace your_user_id with your own if available.
    // window.hj('identify', userId, {
    // country: detectedCountry
    // });

})(jQuery);


var rellax = new Rellax('.rellax', {

});


